package com.huang.controller;

import com.huang.pojo.Order;
import com.huang.service.OrderService;
import com.huang.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/getOrderList")
    public SysResult getOrderList(){

        List<Order> list=orderService.getOrderList();
         return SysResult.success(list);
    }

    //用户提交订单
   @PostMapping("/addOrder")
    public SysResult addOrder(@RequestBody Order order){
       System.out.println(order);
     int a=orderService.addOrder(order.getUsername(),order.getAtrname(),order.getTicketle(),order.getNum(),order.getPrice());
       if (a == 1) {
           return SysResult.success();
       }
     return SysResult.fail();
    }
    //用户获取个人订单信息列表
    @GetMapping("/getUserOrder")
    public SysResult getUserOrder( String username){
      List<Order> list= orderService.getUserOrder(username);
        return SysResult.success(list);

    }
}
